const { cleanDatEnglishText } = require("../src/utils/datTextCleaner");

// 实际的DAT条目
const realDatEntry =
  "*^We$we$$$$$^ ^shall$shall$$$$$^ ^lodge$lodge$$$$$^ ^a$a$$$$$^ ^claim$claim$$$$$^ ^for all$for all$$$$$^ ^the$the$$$$$^ ^losses$loss$$$$$^ ^incurred$incur$$$$$^ ^as$as$$$$$^ ^a$a$$$$$^ ^consequence$consequence$◆$$$$^ ^of$of$$$$$^ ^your$your$$$$$^ ^failure$failure$$$$$^ ^to$to$$$$$^ ^ship$ship$$$$$^ ^our$our$$$$$^ ^order$order$$$$$^ ^in time$in time$$$$$^.^#由于你方未能及时交货，我方将向你方提出由此而遭受的全部损失的索赔。#12.879#19.571##################";

console.log("测试实际DAT条目:\n");
console.log(`原始条目: ${realDatEntry}\n`);

// 提取英语部分（在第一个*^和第一个#之间）
const englishStartIndex = realDatEntry.indexOf("*^");
const englishEndIndex = realDatEntry.indexOf("#");
const englishPart = realDatEntry.substring(englishStartIndex + 2, englishEndIndex);
const chinesePart = realDatEntry.substring(englishEndIndex + 1, realDatEntry.indexOf("#", englishEndIndex + 1));

console.log(`提取的英语部分: ${englishPart}\n`);
console.log(`提取的中文部分: ${chinesePart}\n`);

// 使用我们的工具清理英语部分
const cleanedEnglish = cleanDatEnglishText(englishPart);
console.log(`清理后的英语部分: ${cleanedEnglish}\n`);

// 完整处理结果
console.log("完整处理结果:");
console.log(`${cleanedEnglish}`);
console.log(`${chinesePart}`);

console.log("\n详细处理过程:");
const testCases = [
  "We$we$$$$$^",
  "^shall$shall$$$$$^",
  "^lodge$lodge$$$$$^",
  "^a$a$$$$$^",
  "^claim$claim$$$$$^",
  "^for all$for all$$$$$^",
  "^the$the$$$$$^",
  "^losses$loss$$$$$^",
  "^incurred$incur$$$$$^",
  "^as$as$$$$$^",
  "^a$a$$$$$^",
  "^consequence$consequence$◆$$$$^",
  "^of$of$$$$$^",
  "^your$your$$$$$^",
  "^failure$failure$$$$$^",
  "^to$to$$$$$^",
  "^ship$ship$$$$$^",
  "^our$our$$$$$^",
  "^order$order$$$$$^",
  "^in time$in time$$$$$^.",
];

testCases.forEach((testCase, index) => {
  const result = cleanDatEnglishText(testCase);
  console.log(`${index + 1}. "${testCase}" -> "${result}"`);
});
